home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-06-05 | 1.6 KB | 65 lines | [MATS/MATL] |
- echo off;
- % NUMERICAL METHODS: MATLAB Programs, (c) John H. Mathews 1994
- % To accompany the text:
- % NUMERICAL METHODS for Mathematics, Science and Engineering, 2nd Ed, 1992
- % Prentice Hall, Englewood Cliffs, New Jersey, 07632, U.S.A.
- % This free software is complements of the author.
-
- % Algorithm 11.1 (Power Method).
- % Section 11.2, The Power Method, Page 557
- echo on; clc; format long; hold off; clear
-
- % POWER METHOD FOR FINDING AN EIGEN-PAIR
-
- % Assume that A is an n by n real matrix and that it
-
- % has a full set of eigenvectors V , V ,..., V .
- % 1 2 n
-
- % The power method of iteration is used to find the
-
- % dominant eigenvalue and its corresponding eigenvector.
-
- % Remark. power.m is used for Algorithm 11.1
-
- pause % Press any key to continue.
-
- clc;
-
- % Iteration will continue until each coordinate of the
-
- % eigenvector has converged with an error less than
-
- % epsilon or the maximum number of iterations is reached.
-
- % Place the matrix in A
-
- % Place the matrix in A and starting vector in X.
-
- % Place the tolerance in epsilon
-
- % Place the maximum number of iterations in max1
-
- A = [ 0 11 -5;
- -2 17 -7;
- -4 26 -10];
-
- [n,n] = size(A);
- X = ones(n,1);
- epsilon = 1e-14;
- max1 = 100;
-
- [lambda,V] = power(A,X,epsilon,max1,1)
-
- pause % Press any key to continue.
-
- clc;
- Mx1 = 'Implementation of the power method.';
- Mx2 = 'The matrix A is: ';
- Mx3 = 'The dominant eigenvalue of A is: ';
- Mx4 = 'The dominant eigenvector of A is: ';
- clc,echo off,diary output,...
- disp(''),disp(Mx1),disp(''),disp(Mx2),disp(A),...
- disp(Mx3),disp(lambda),disp(Mx4),disp(V),...
- diary off,echo on
-